package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MesChkResult;
import com.ruoyi.system.service.IMesChkResultService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 检测结果接口 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/mesChkResult")
public class MesChkResultController extends BaseController
{
    private String prefix = "system/mesChkResult";
	
	@Autowired
	private IMesChkResultService mesChkResultService;
	
	@RequiresPermissions("system:mesChkResult:view")
	@GetMapping()
	public String mesChkResult()
	{
	    return prefix + "/mesChkResult";
	}
	
	/**
	 * 查询检测结果接口列表
	 */
	@RequiresPermissions("system:mesChkResult:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(MesChkResult mesChkResult)
	{
		startPage();
        List<MesChkResult> list = mesChkResultService.selectMesChkResultList(mesChkResult);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出检测结果接口列表
	 */
	@RequiresPermissions("system:mesChkResult:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MesChkResult mesChkResult)
    {
    	List<MesChkResult> list = mesChkResultService.selectMesChkResultList(mesChkResult);
        ExcelUtil<MesChkResult> util = new ExcelUtil<MesChkResult>(MesChkResult.class);
        return util.exportExcel(list, "mesChkResult");
    }
	
	/**
	 * 新增检测结果接口
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存检测结果接口
	 */
	@RequiresPermissions("system:mesChkResult:add")
	@Log(title = "检测结果接口", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(MesChkResult mesChkResult)
	{		
		return toAjax(mesChkResultService.insertMesChkResult(mesChkResult));
	}

	/**
	 * 修改检测结果接口
	 */
	@GetMapping("/edit/{serial}")
	public String edit(@PathVariable("serial") String serial, ModelMap mmap)
	{
		MesChkResult mesChkResult = mesChkResultService.selectMesChkResultById(serial);
		mmap.put("mesChkResult", mesChkResult);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存检测结果接口
	 */
	@RequiresPermissions("system:mesChkResult:edit")
	@Log(title = "检测结果接口", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(MesChkResult mesChkResult)
	{		
		return toAjax(mesChkResultService.updateMesChkResult(mesChkResult));
	}
	
	/**
	 * 删除检测结果接口
	 */
	@RequiresPermissions("system:mesChkResult:remove")
	@Log(title = "检测结果接口", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(mesChkResultService.deleteMesChkResultByIds(ids));
	}
	
}
